package com.aaa.rabbitmq.eight;

import com.aaa.rabbitmq.one.util.RabbitMQUtil;
import com.rabbitmq.client.BuiltinExchangeType;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.DeliverCallback;

import java.nio.charset.StandardCharsets;

/**
 * 消费死信队列
 */
public class ReceiveLogsDead02 {

    //死信队列
    public static final String DEAD_QUEUE_NAME = "dead_queue";

    public static void main(String[] args) throws Exception {
        Channel channel = RabbitMQUtil.getChannel();

        //接受消息的回调
        DeliverCallback callback = (tag, message )->{
            System.out.println("ReceiveLogsTopic02：打印收到的消息"+new String(message.getBody(), StandardCharsets.UTF_8)+"=====RoutingKey: "+message.getEnvelope().getRoutingKey());
        };
        //消费消息
        channel.basicConsume(DEAD_QUEUE_NAME,true,callback,consumerTag ->{});
    }
}
